﻿Imports ConexionBD
Imports System.Data.Common

Public Class Menu

    Public Shared Function ConsxModuloPerfil(modulo As String, perfil As String) As DataTable
        Dim conexion As New ConexionBD.ConexionBD()
        Dim dtConsulta As New DataTable
        If conexion.Conectar() Then
            Dim sentencia As String
            sentencia = "select * from menu inner join menu_perfil on menu.cod_menu=menu_perfil.cod_menu where menu.cod_modulo=@P_MODULO and menu_perfil.perfil=@P_PERFIL"
            conexion.ParametroEntrada = New List(Of DbParameter)
            conexion.ParametroEntrada.Add(ConexionBD.ConexionBD.ParamInString(conexion, modulo, "P_MODULO"))
            conexion.ParametroEntrada.Add(ConexionBD.ConexionBD.ParamInString(conexion, perfil, "P_PERFIL"))
            dtConsulta = conexion.Consulta(sentencia)
            conexion.Desconectar()
        End If
        Return dtConsulta
    End Function

    Public Shared Function ConsultarAll() As DataTable
        Dim conexion As New ConexionBD.ConexionBD()
        Dim dtConsulta As New DataTable
        If conexion.Conectar() Then
            Dim sentencia As String
            sentencia = "select * from menu"
            conexion.ParametroEntrada = New List(Of DbParameter)
            dtConsulta = conexion.Consulta(sentencia)
            conexion.Desconectar()
        End If
        Return dtConsulta
    End Function
End Class
